package com.weiqiao.report.distributior.repository.impl;

import com.mongodb.Block;
import com.mongodb.client.AggregateIterable;
import com.mongodb.client.MongoCollection;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;
import com.weiqiao.base.dao.impl.BaseMongoDaoImpl;
import com.weiqiao.report.distributior.repository.DistributionStatisticsRepository;

import java.util.ArrayList;
import java.util.List;

/**
* @author PEI
* @date 2020-08-10
*/
@Repository("DistributionStatisticsRepositoryImpl")
public class DistributionStatisticsRepositoryImpl extends BaseMongoDaoImpl implements DistributionStatisticsRepository {

    private final static String collectionName = "distribution_Statistics_";

    @Override
    public List<String> statisticsList(int company_id, List<Document> docList) {
        return super.findAggregate(collectionName + company_id, docList);
    }

    @Override
    public List<String> getList(int company_id, Bson filter, Pageable pageable) {
    return this.getListAndPage(collectionName + company_id, filter, pageable);
    }


    @Override
    public boolean addInfo(int company_id, String json) {
    return this.inSert(collectionName + company_id, json);
    }

    @Override
    public String getOne(int company_id, Bson filter) {
    return super.findOne(collectionName + company_id, filter);
    }

    @Override
    public boolean updateInfo(int company_id, Bson filter, Document doc) {
    return this.updateOne(collectionName + company_id, filter, doc, false);
    }

    @Override
    public int countNum(int company_id, Bson filter) {
    int count = this.statististics(collectionName + company_id, filter);
    return count;
    }

}